/**
 * @fileOverview
 * WashizuMahjong.
 * http://code.google.com/p/washizu-mahjong/
 */
//set prototype function
Array.prototype.clone=function(){function d(a){if(null==a)return null;var c=new a.constructor,b;for(b in a)c[b]="object"==typeof a[b]?d(a[b]):a[b];return c}var c=[],a;for(a=0;a<this.length;a++)c[a]="object"==typeof this[a]?d(this[a]):this[a];return c};
Array.prototype.remove=function(a){a=this.indexOf(a);return 0<=a?(this.splice(a,1),!0):!1};
Array.prototype.removeByIndex=function(a){if("number"!=typeof(a+0))return!1;return 0<=a?(this.splice(a,1),!0):!1};
Array.prototype.addAt=function(a,b){if("number"!=typeof a||this.length<a)return!1;this.splice(a,0,b);return!0};
Array.prototype.swap=function(a,b){if("number"!=typeof a||this.length<a||"number"!=typeof b||this.length<b||a==b)return!1;var c=this[a];this.splice(a,1,this[b]);this.splice(b,1,c);return!0};
Array.prototype.lastItem=function(){return this[this.length-1]};

/**
 * All tiles in the game.
 * it store all datas of the tiles, therefore when it need to start new game, just need to clone this to reset the data of the tiles.
 * @type MahjongTile[]
 * @constant
 */
var DEFAULT_TILES =[],
/**
 * The tiles in the game. Items in the array will be removed due to the game. Also, when {@link startNewRound} function run, it will also clone the DEFAULT_TILES.
 * @see DEFAULT_TILES
 * @see Game-startNewRound
 * @see Array#clone
 * @type MahjongTile[]
 */
gameTiles = [],
/**
 * @type Player[]
 */
players = [],
/**
 * the hidden tile, only used for display hidden tiles, such as hidden <span class="unicode">&#126976;</span>
 * @type MahjongTile
 * @nullable true
 */
hiddenTile = null;
